package com.coursehub.course.entity;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import lombok.NoArgsConstructor;

/**
 * 班级学生关联实体
 */
@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "classes_student")
public class ClassesStudent {
    
    @EmbeddedId
    private ClassesStudentId id;
    
    @MapsId("classesId")
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "classes_id", nullable = false)
    private Classes classes;
    
    // 在微服务架构中，我们不维护User实体的引用
    // 只存储userId，通过服务调用获取用户信息
    
    public ClassesStudent(ClassesStudentId id, Classes classes) {
        this.id = id;
        this.classes = classes;
    }
}